﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentNHibernate.Mapping;
using YasharEl.Infrastructure.Core.EntityModel.Prototype;
using YasharEl.Infrastructure.PersistenceModel.NHibernate.UserTypes;
using YasharEl.Infrastructure.ProcessEngine.EntityModel;
using YasharEl.Infrastructure.ProcessEngine.EntityModel.Prototype;
using YasharEl.Infrastructure.ProcessEngine.Prototype;

namespace YasharEl.Infrastructure.ProcessEngine.PersistenceModel.NHibernate.Prototype.Mappings
{
    public class ProcessPropertyInstanceEntityMap : SubclassMap<ProcessPropertyInstanceEntity>
    {
        public ProcessPropertyInstanceEntityMap()
        {
            Extends<AbstractPropertyInstanceEntity>();
            DiscriminatorValue(ProcessDefinitionObjectType.ProcessDefinition.Value.ToString());

            Map(e => e.PrototypedObjectType)
                .Column("PrototypedObjectType")
                .Not.Nullable()
                .CustomType<EnumerationType<ProcessObjectType>>();

            References(e => e.PrototypedEntity)
                .Column("PrototypedObjectId")
                .Class<ProcessEntity>()
                .LazyLoad();
        }
    }
}
